//
//  LMReplyView.m
//  舍品
//
//  Created by 楼 眉 on 16/3/11.
//  Copyright © 2016年 楼 眉. All rights reserved.
//

#import "LMReplyView.h"
#import <YYWebImage.h>

@interface LMReplyView ()
@property (nonatomic,strong)  UIImageView *iconImage;
@end
@implementation LMReplyView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        UIImageView *iconImage = [[UIImageView alloc]init];
        self.iconImage = iconImage;
        [self addSubview:iconImage];
        self.backgroundColor = LMRandomColor;
    }
    return self;
}

- (void)setUser:(LMUser *)user
{
    _user = user;
    [user fetchIfNeededInBackgroundWithBlock:^(AVObject *object, NSError *error) {
        self.iconImage.frame = CGRectMake(0, 0, 33, 33);
        [self.iconImage yy_setImageWithURL:[NSURL URLWithString:user.iconImage.url] placeholder:nil];
        self.iconImage.center = self.center;
        self.replyViewHeight = CGRectGetMaxY(self.iconImage.frame) + 30;
    }];

}

- (void)layoutSubviews
{
}

+ (instancetype)lm_createReplyViewWIthReply:(LMReply *)reply lmUser:(LMUser *)user
{
    LMReplyView *replyView = [[LMReplyView alloc]init];
    replyView.user = user;
    replyView.reply = reply;
    return replyView;
}

//- (void)setFrame:(CGRect)frame
//{
//    CGRect myFrame = self.frame;
//    myFrame.size.height = self.replyViewHeight;
//    self.frame = myFrame;
//}
@end
